/*OWmq6Ugo6jPE4W7xoi1UXr4Tp1/n/Vi+P1J4TZWCBleFqRbMKl/Fh/GX//kGX13Z*/
import { pageConfig } from '../const';
import { dealConditions } from './searchBtnClick';
import fa from 'fa';
import ampub from 'ampub';
const { fa_components } = fa;
const { ReferLinkage } = fa_components;
const { referLinkageClear } = ReferLinkage;
const { searchAreaId } = pageConfig;

// 参照过滤业务单元
const { components: { assetOrgMultiRefFilter: { isMultiCorpRefHandler, renderCompleteEvent } } } = ampub;

/**
 * 查询区编辑后事件
 * @param {*} props 
 * @param {*} moduleId 
 * @param {*} key 
 * @param {*} value 
 * @param {*} oldValue 
 * @param {*} val 
 */
export default function afterEvent(props, moduleId, key, value, oldValue, val) {
	//联动清除
	referLinkageClear.call(this, props, key);
	let queryInfo = props.search.getQueryInfo(searchAreaId, false);
	let queryconditions = [];
	if (queryInfo && queryInfo.querycondition && queryInfo.querycondition.conditions) {
		queryconditions = queryInfo.querycondition.conditions;
	}
	let conditions = dealConditions.call(this, props, queryconditions);
	props.button.setButtonDisabled([ 'Print', 'Output', 'Preview' ], true);
	this.setState({ conditions: conditions, pks: 0 });

    // 主组织编辑后：主组织关联参照字段控制其业务单元是否显示
	if (key === 'pk_org') {
		renderCompleteEvent.call(this, this.props, searchAreaId, 'pk_org', orgAfterEvent.bind(this));
	}
}



/**
 * 主组织关联参照字段控制其业务单元是否显示
 * @param {*s} field 
 * @param {*} value 
 */
 export function orgAfterEvent(field, value) {
	if (field === 'pk_org') {
		//获取账簿
		isMultiCorpRefHandler.call(this, this.props, value, searchAreaId, [
			// 供应商
			'provider',
			// 项目档案
			'pk_jobmngfil'
		]);
	}
}




/*OWmq6Ugo6jPE4W7xoi1UXr4Tp1/n/Vi+P1J4TZWCBleFqRbMKl/Fh/GX//kGX13Z*/